package com.bplow.deep.base.concurrent.synclock;

import java.lang.reflect.AnnotatedElement;

import org.springframework.core.annotation.AnnotationUtils;

public class SyncLockAnnotationParser {

	public SyncLockAttribute parseTransactionAnnotation(AnnotatedElement ae) {
		SyncLock ann = AnnotationUtils.getAnnotation(ae, SyncLock.class);
		if (ann != null) {
			
			SyncLockAttribute attr = new SyncLockAttribute();
			
			attr.setLockId(ann.synKey());
			attr.setKeepMills(ann.keepMills());
			attr.setMaxSleepMills(ann.maxSleepMills());
			attr.setSleepMills(ann.sleepMills());
			attr.setWait(ann.toWait());
			
			return attr;
		}
		else {
			return null;
		}
	}
	
}
